package com.zxs.common.entity;

import com.zxs.common.enums.ResultCodeEnum;
import lombok.Data;

/**
 * 统一返回类
 * @author zxs
 * @date 2025/11/4 下午9:18
 */
@Data
public class Result<T> {

    // 返回状态码
    private int code;

    // 提示信息
    private String message;

    // 返回数据
    private T data;

    // 日志编号
    private Long reqUuid;

    // 是否成功
    private Boolean success;

    public static Result success(String message) {
        Result result = new Result();
        result.setSuccess(true);
        result.setCode(ResultCodeEnum.SUCCESS.getCode());
        result.setMessage(message);
        return result;
    }

    public static Result success(String message, Object data) {
        Result result = new Result();
        result.setSuccess(true);
        result.setCode(ResultCodeEnum.SUCCESS.getCode());
        result.setData(data);
        result.setMessage(message);
        return result;
    }

    public static Result failed(String message) {
        Result result = new Result();
        result.setSuccess(false);
        result.setCode(ResultCodeEnum.FAIL.getCode());
        result.setMessage(message);
        return result;
    }

}